// pages/allGoods/allGoods.js

let app = getApp();
let util = require("../../utils/util.js");
let baseImgUrl = util.baseImgUrl;
let orderUr=baseImgUrl + "order.png";//按价格升序排列
let inverOrderUrl=baseImgUrl + "inver-order.png";//按价格降序排列
let unOrder= baseImgUrl + "un-order.png";//无序排列

Page({

  /**
   * 页面的初始数据
   */
  data: {
    activeIndex:0,//导航栏默认选择默认
    orderUrl:baseImgUrl+"order.png",//按价格升序排列
    inverOrderUrl:baseImgUrl+"inver-order.png",//按价格降序排列
    unOrder:baseImgUrl+"un-order.png",//无序排列
    getmoreUrl:baseImgUrl+"getmorePic.png",//更多图片
    //导航数据
    navlist:[{
      id:0,
      name:"默认",
      picurl:""
    }, {
        id: 0,
        name: "销量",
        picurl: ""
      }, {
        id: 0,
        name: "价格",
        picurl: unOrder
      }],
    goodslist: [{
      id: 0,
      goodsUrl: baseImgUrl + "goods1.png",
      goodsname: "女友礼物精选集",
      content: "商品的介绍内容品的介绍内容商品的介绍内容商品的介绍内容s",
      biaoqian: ["今日秒杀", "HOT热卖", "特卖"],
      price: 45,
      sale: true,
      yuanjia: 60,
      scanNum: 1234,
      scanUrl: baseImgUrl + "scan.png",
    }, {
      id: 1,
      goodsUrl: baseImgUrl + "goods2.png",
      goodsname: "女友礼物精选集",
      content: "商品的介绍内容",
      biaoqian: ["今日秒杀"],
      price: 95,
      sale: false,
      yuanjia: 95,
      scanNum: 1200,
      scanUrl: baseImgUrl + "scan.png",
    }, {
      id: 2,
      goodsUrl: baseImgUrl + "goods2.png",
      goodsname: "女友礼物精选集",
      content: "商品的介绍内容商",

      price: 125,
      sale: true,
      yuanjia: 155,
      scanNum: 1000,
      scanUrl: baseImgUrl + "scan.png",
    }, {
      id: 3,
      goodsUrl: baseImgUrl + "goods2.png",
      goodsname: "女友礼物精选集",
      content: "商品的介绍内容商品的介绍内容商品的介绍内容商品的介绍内容",
      biaoqian: ["今日秒杀", "HOT热卖", "特卖"],
      price: 125,
      sale: true,
      yuanjia: 125,
      scanNum: 1000,
      scanUrl: baseImgUrl + "scan.png",
    }, {
      id: 4,
      goodsUrl: baseImgUrl + "goods2.png",
      goodsname: "女友礼物精选集",
      content: "商品的介绍内容商",
      biaoqian: ["今日秒杀", "特卖"],
      price: 125,
      sale: true,
      yuanjia: 155,
      scanNum: 1000,
      scanUrl: baseImgUrl + "scan.png",
    }, {
      id: 5,
      goodsUrl: baseImgUrl + "goods2.png",
      goodsname: "女友礼物精选集",
      content: "商品的介绍内容商品的介绍内容商品的介绍内容商品的介绍内容",
      biaoqian: ["今日秒杀", "HOT热卖",],
      price: 125,
      sale: false,
      yuanjia: 155,
      scanNum: 1000,
      scanUrl: baseImgUrl + "scan.png",
      }],
    showclasses:false,//分类面板默认不显示
    activeClass:0,//分类默认选择全部
    classesBar:"为您精选以下标签",
       classeslist: [{
        id: "0",
        name: "全部",
      },
      {
        id: "1",
        name: "营养保健",
      },
      {
        id: "2",
        name: "美妆达人",
      }, {
        id: "3",
        name: "饰品包包",
      }, {
        id: "4",
        name: "个人洗护",
      }, {
        id: "5",
        name: "健身达人",
      }, {
        id: "6",
        name: "旅游",
      },],
    quickflag:false,//默认不展开
    arrow_left: baseImgUrl + "arrow2_left.png",
    arrow_right: baseImgUrl + "arrow2_right.png",
    quciklist: [{
      id: 0,
      quickpic: baseImgUrl + "home_qu.png",
      name: "首页"
    }, {
      id: 1,
      quickpic: baseImgUrl + "buycar_qu.png",
      name: "购物车"
    }, {
      id: 2,
      quickpic: baseImgUrl + "home_qu.png",
      name: "商品收藏"
    }, {
      id: 3,
      quickpic: baseImgUrl + "me_qu.png",
      name: "我的"
    }, {
      id: 4,
      quickpic: baseImgUrl + "search_qu.png",
      name: "搜索"
    }, {
      id: 5,
      quickpic: baseImgUrl + "share_qu.png",
      name: "分享赚积分"
    }],

  },
/********点击导航 切换数据*********** */
  choseNav:function(e){
      var that = this;
      var activeIndex=e.currentTarget.dataset.index;
      console.log(activeIndex);
      that.setData({
        activeIndex: activeIndex
      })
      util.loading();
    //请求接口，获取数据

  },

  /*******点击右侧显示分类面板****** */
  showclasses:function(){
    var that=this;
    that.setData({
      showclasses:true
    })
  },

  /***********关闭附近区域弹出框************* */
  hideGrey: function () {
    var that = this;
    that.setData({
      showfujin: false,
      showclasses: false
    })
  },

  /*************点击弹出面板的标签*****************/
  choseClass: function (e) {
    var that = this;
    var activeClass = e.currentTarget.dataset.index;
    console.log(e);
    that.setData({
      activeClass: activeClass,
      showclasses: false,
      
    })

    console.log(e);

    util.loading();
  },

  /*********打开快速导航******* */
  openBtn: function () {
    var that = this;
    that.animation.translateX(-65).step()

    that.setData({
      quickflag: true,
      animation: this.animation.export(),

    })
  },
  /********收起快速导航******* */
  closeBtn: function () {
    var that = this;
    that.animation.translateX("50%").step()

    that.setData({
      animation: this.animation.export(),

    })
    setTimeout(function () {
      that.setData({

        quickflag: false,
      })
    }, 500)
  },
 
  /**********快速导航 点击跳转************* */

  quickGo: function (e) {
    console.log(e);
    var thisIndex = e.currentTarget.dataset.index;

    if (thisIndex == 0) {
      wx.switchTab({
        url: '/pages/index/index',
        success: function (res) { },
        fail: function (res) { console.log(res) },
        complete: function (res) { },
      })
    }
    if (thisIndex == 1) {

    }
    if (thisIndex == 2) {

    }
    if (thisIndex == 3) {
      wx.switchTab({
        url: '/pages/mine/mine',
      })
    }

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    this.animation = wx.createAnimation({
      duration: 500
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})